/**
 * Visual Blocks Language
 *
 * Copyright 2012 Google Inc.
 * http://blockly.googlecode.com/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Blocks for plane demo.
 * @author fraser@google.com (Neil Fraser)
 */
'use strict';

Blockly.Language.viet_ra = {
  // Seat variable setter.
  helpUrl: Blockly.LANG_VARIABLES_SET_HELPURL,
  deletable: false,
  init: function() {
    this.setColour(330);
    this.appendValueInput('VALUE')
        .appendTitle("WRITE");
  }
};
Blockly.JavaScript.viet_ra = function() {
  var code = Blockly.JavaScript.valueToCode(this, 'VALUE', Blockly.JavaScript.ORDER_ASSIGNMENT);
  return code;
};
Blockly.Language.so_nho_nhat = {
  // Basic arithmetic operator.
  helpUrl: Blockly.LANG_MATH_ARITHMETIC_HELPURL,
  init: function() {
    this.setColour(230);
	this.appendDummyInput()
        .appendTitle("Min(");
    this.setOutput(true, String);
    this.appendValueInput('A')
        .setCheck(String);
    this.appendValueInput('B')
        .setCheck(String)
        .appendTitle(",");
	this.appendDummyInput()
        .appendTitle(")");
    this.setInputsInline(true);
    // Assign 'this' to a variable for use in the tooltip closure below.
  }
};
Blockly.JavaScript.so_nho_nhat = function() {
  
  //return ['Min(', Blockly.JavaScript.ORDER_MEMBER];
  //var code = Blockly.JavaScript.valueToCode(this, 'MIN', Blockly.JavaScript.ORDER_MEMBER) || '\'\'';
  var code = "Min(" + Blockly.JavaScript.valueToCode(this, 'A', Blockly.JavaScript.ORDER_ASSIGNMENT) + "," + Blockly.JavaScript.valueToCode(this, 'B', Blockly.JavaScript.ORDER_ASSIGNMENT) + ")";
  //return code;
  return [code, Blockly.JavaScript.ORDER_MEMBER];
};

Blockly.Language.so_a = {
  helpUrl: '',
  init: function() {
    this.setColour(290);
	this.setOutput(true, String);
    this.appendDummyInput()
        .appendTitle('a');
  }
};
Blockly.JavaScript.so_a = function() {
  
  return ['a', Blockly.JavaScript.ORDER_MEMBER];
};
Blockly.Language.so_b = {
  helpUrl: '',
  init: function() {
    this.setColour(290);
	this.setOutput(true, String);
    this.appendDummyInput()
        .appendTitle('b');
  }
};
Blockly.JavaScript.so_b = function() {
  
  return ['b', Blockly.JavaScript.ORDER_MEMBER];
};
Blockly.Language.so_c = {
  helpUrl: '',
  init: function() {
    this.setColour(290);
	this.setOutput(true, String);
    this.appendDummyInput()
        .appendTitle('c');
  }
};
Blockly.JavaScript.so_c = function() {
  
  return ['c', Blockly.JavaScript.ORDER_MEMBER];
};
Blockly.Language.so_d = {
  helpUrl: '',
  init: function() {
    this.setColour(290);
	this.setOutput(true, String);
    this.appendDummyInput()
        .appendTitle('d');
  }
};
Blockly.JavaScript.so_d = function() {
  
  return ['d', Blockly.JavaScript.ORDER_MEMBER];
};
Blockly.Language.he_so = {
  helpUrl: 'http://code.google.com/p/blockly/wiki/Turn',
  init: function() {
    this.setColour(290);
	this.setOutput(true, String);
    this.appendDummyInput()
        .appendTitle(new Blockly.FieldDropdown(this.CACHESO), 'DIR');
  }
};
Blockly.Language.he_so.CACHESO =
    [["a", 'a'], ['b', 'b'], ['c', 'c'], ['d', 'd']];
	
